//
//  TMNetHandleInterface.m
//  TaskManager
//
//  Created by vip on 16/5/19.
//  Copyright © 2016年 M&H. All rights reserved.
//

#import "TMNetHandleInterface.h"

@implementation TMNetHandleInterface
+(void)handleNetDataType:(TMNetHandleType)type withNetData:(id)responseData finish:(void (^)(NSDictionary *))hander{
    
    if ([responseData isKindOfClass:[NSDictionary class]]) {
       hander((NSDictionary*)responseData);
        return;
    }
    
    switch (type) {
        case TMNetHandleTypeData:
        {
            hander(@{@"data":[[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding]});
        }
            break;
        case TMNetHandleTypeJSON:
        {
            NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil];
            hander(dic);
        }
            break;
        case TMNetHandleTypeXML:
        {
            
        }
            break;
        default:
            break;
    }
}
@end
